package com.task.www.constant;

import com.task.www.dao.MechantData;
import com.task.www.po.Food;
import com.task.www.po.Merchant;
import com.task.www.util.Clear;

import java.util.ArrayList;

public class ShowMerchant {
    private MechantData md = new MechantData();
    public  void showMerchant(String accout){
        Merchant mc = md.getaccout(accout);
        System.out.print("店铺名称：");
        if(mc.getRestaurant_name()==null){
            System.out.println("您还没有设置店铺名称");
        }
        else{
            System.out.println(mc.getRestaurant_name());
        }

        System.out.print("店铺介绍：");
        if(mc.getRestaurant_introduce()==null){
            System.out.println("您还没有设置店铺介绍");
        }
        else{
            System.out.println(mc.getRestaurant_introduce());
        }


        System.out.print("\n当前收入："+ mc.getMonney() + "\n等待接单数量：" + mc.getWait() +
                "\n已接单数量：" + mc.getAlready() + "\n\n菜单：");
        ArrayList<String> menusin = md.getmenuSimple(accout);
        //遍历输出菜单
        if(!menusin.isEmpty()) {
            for (int i = 0; i < menusin.size(); i++) {
                if (i % 3 == 0) {
                    System.out.println();
                }
                System.out.print(menusin.get(i) + "     ");
            }
        }
        else{
            System.out.println("你还没有设置你的菜单");
        }

        System.out.print("\n优惠券：");
        ArrayList<Integer> coupon = md.getCoupon(accout);
        if(!coupon.isEmpty()) {
            for (int i = 0; i < coupon.size(); i++) {
                if (i % 4 == 0) {
                    System.out.println();
                }
                if (i % 2 == 0) {
                    System.out.print("满" + coupon.get(i));
                }
                if (i % 2 == 1) {
                    System.out.print("减" + coupon.get(i) + "    ");
                }
            }
        }
        else{
            System.out.println("你还没有设置优惠券");
        }

        //等输出完后
        System.out.println("\n\n请选择如下选项\n【1】店铺名称\n【2】店铺介绍\n【3】菜单\n【4】优惠券\n【5】接单\n【6】刷新\n【7】退出");
    }

    public void showname(String accout){
        Clear.clear();
        Merchant mc = md.getaccout(accout);
        System.out.println("店铺名称：" + mc.getRestaurant_name());
        System.out.println("\n请选择如下操作\n【1】修改店铺名称\n【2】返回上一页面");
    }

    public void showIntroduce(String accout){
        Clear.clear();
        Merchant mc = md.getaccout(accout);
        System.out.println("店铺介绍：" + mc.getRestaurant_introduce());
        System.out.println("\n请选择如下操作\n【1】修改店铺介绍\n【2】返回上一页面");
    }

//   详细菜单
    public int showMenu(String accout){
        System.out.println("菜单：\n");
        ArrayList<Food> foods = md.selectMenu(accout);
        Food food = null;
        for (int i = 1; i < foods.size()+1; i++) {
            food = foods.get(i-1);
            System.out.println("【" + i + "】"+food.getName()+"\n￥"+food.getPrice());
            if(food.getIntroduce()!=null) {
                System.out.println(food.getIntroduce());
            }
            else{
                System.out.println("你还没有设置这道菜的介绍");
            }
            System.out.println();
            if(i==foods.size()){
                System.out.println("【" + ++i + "】返回上一页面"+"\n");
            }
        }
        System.out.println("请根据标号选择菜或返回上一页面");
        return foods.size()+1;
    }

    public void showFood(ArrayList<String> food){
        Clear.clear();
        System.out.println("菜名：" + food.get(0));
        System.out.println("价格：" + food.get(1));
        System.out.println("介绍：" + food.get(2));
        System.out.println("自己的评论：" + food.get(3));
        System.out.println("\n顾客的评论：");
        for (int i = 4; i < food.size(); i++) {
            System.out.println("用户" + food.get(i) + "：" + food.get(++i));
        }

        System.out.println("\n请选择修改如下选项：\n【1】菜名\n【2】价格\n【3】介绍\n【4】评论\n【5】返回上一页面");
    }

    public void operationCoupon(){
        Clear.clear();
        System.out.println("请选择如下操作\n\n[1]增加一种优惠券\n[2]删除某种优惠券\n[3]修改某种优惠券\n[4]返回上一页面");
    }

    public void showbuy(ArrayList<String> buy){
        Clear.clear();
        int i = 0;
        for (; i < buy.size(); i++) {
            System.out.println("【" + (i+1) + "】菜名：" + buy.get(i) + "     等待接单");
        }
        System.out.println("【" + (i+1) + "】返回上一页面");
        System.out.println("\n请选择接单或返回上一页面");
    }
}
